//
//  DoubleLabCell.m
//  KuWoCan
//
//  Created by hwd on 17/3/16.
//  Copyright © 2017年 hwd. All rights reserved.
//

#import "DoubleLabCell.h"

@interface DoubleLabCell ()

@property (nonatomic,strong) UILabel *leftLab;

@property (nonatomic,strong) UILabel *rightLab;

@property (nonatomic, strong) UILabel *unitsLabel;

@end

@implementation DoubleLabCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier])
    {
        [self setUpUI];
    }
    return self;
}

- (void)setUpUI
{
    _leftLab = [UILabel new];
    _leftLab.font = KwFont(14);
    _leftLab.textColor = [UIColor grayColor];
    _leftLab.text = _constStr;
    [self addSubview:_leftLab];
    [_leftLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@20);
        make.top.equalTo(@20);
        make.height.equalTo(@14);
    }];

    self.unitsLabel = [UILabel new];
    self.unitsLabel.font = KwFont(14);
    self.unitsLabel.textColor = KwBlueColor;
    [self addSubview:self.unitsLabel];
     self.unitsLabel.textAlignment = NSTextAlignmentRight;
    [self.unitsLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self).offset(-20 * screenW_6);
        make.top.and.bottom.equalTo(_leftLab);
        make.width.equalTo(@50);
    }];
    
    _rightLab = [UILabel new];
    _rightLab.numberOfLines = 0;
    _rightLab.font = KwFont(14);
    _rightLab.textColor = KwBlueColor;
    _rightLab.text = _paraStr;
    _rightLab.numberOfLines = 0;
    [self addSubview:_rightLab];
    [_rightLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@130);
        make.top.equalTo(_leftLab.mas_top);
        make.right.equalTo(self.unitsLabel.mas_left).offset(-5);
        //        make.bottom.equalTo(@(-10 * screenW_6));
        //        make.height.equalTo(@14);
    }];
    
    UIView *lineView = [UIView new];
    lineView.backgroundColor = KwGaryColor;
    [self addSubview:lineView];
    [lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.equalTo(@1.5);
        make.left.equalTo(_leftLab.mas_left);
        make.right.equalTo(@-20);
        make.top.equalTo(_rightLab.mas_bottom).offset(20);
        make.bottom.equalTo(@0);
    }];
}

- (void)setConstStr:(NSString *)constStr
{
    _constStr = constStr;
    _leftLab.text = _constStr.isEmptyString ? @" " : _constStr;
    if (comparisonString(constStr, @"费效比率") || comparisonString(constStr, @"期间费效比率")) {
        self.unitsLabel.text = @"%";
    } else if (comparisonString(constStr, @"销售额") || comparisonString(constStr, @"费用预算") || comparisonString(constStr, @"费用总计") || comparisonString(constStr, @"费用") || comparisonString(constStr, @"期间销售额")){
        self.unitsLabel.text = @"元";
    } else if (comparisonString(constStr, @"注册资金")) {
        self.unitsLabel.text = @"万元";
    } else if (comparisonString(constStr, @"数量") || comparisonString(constStr, @"门店数量")) {
        self.unitsLabel.text = @"家";
    } else if (comparisonString(constStr, @"面积")) {
        self.unitsLabel.text = @"平方米";
    } else if (comparisonString(constStr, @"年经营额") || comparisonString(constStr, @"年销售额")) {
        self.unitsLabel.text = @"万元";
    } else {
        self.unitsLabel.text = @"";
    }

}

- (void)setParaStr:(NSString *)paraStr
{
    _paraStr = paraStr;
    _rightLab.text = _paraStr.isEmptyString ? @" " : _paraStr;
}

@end
